package cn.sciento.farm.devicemanager.service.impl;

import cn.sciento.farm.devicemanager.dao.entity.DevFertilizerChannel;
import cn.sciento.farm.devicemanager.dao.mapper.DevFertilizerChannelMapper;
import cn.sciento.farm.devicemanager.service.FertilizerChannelService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 水肥通道管理 服务类
 * </p>
 *
 * @author wumu
 * @since 2019-05-14
 */
@Service
public class FertilizerChannelServiceImpl implements FertilizerChannelService {

    @Autowired
    private DevFertilizerChannelMapper fertilizerChannelMapper;



    @Override
    public DevFertilizerChannel getById(Long id) {
        return fertilizerChannelMapper.selectById(id);
    }



    @Override
    public int insert(DevFertilizerChannel channel) {
        return fertilizerChannelMapper.insert(channel);
    }

    @Override
    public List<DevFertilizerChannel> getChannelList(String eui) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("eui",eui);
        queryWrapper.orderByAsc("channel_no");
        return fertilizerChannelMapper.selectList(queryWrapper);
    }

    @Override
    public DevFertilizerChannel getChannel(String eui, Integer channelNo) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("eui",eui);
        queryWrapper.eq("channel_no",channelNo);
        return fertilizerChannelMapper.selectOne(queryWrapper);
    }

    @Override
    public int updateById(DevFertilizerChannel channel) {
        return fertilizerChannelMapper.updateById(channel);
    }
}
